/**
 * 数据库连接
 */

const mongoose = require('mongoose')
const config = require('./index')
const log4jsHelper = require("../utils/log4jsHelper");

mongoose.connect(config.URL2, {
  useNewUrlParser: true,
  useUnifiedTopology: true
})

const db = mongoose.connection

// 连接失败
db.on('error', () => {
  log4jsHelper.error("mongodb连接失败");
})


// 连接成功
db.on('open', () => {
  log4jsHelper.info("mongodb 连接成功");
})